vpath %.c = api/
vpath %.h = inlcude/

PWD = $(shell pwd)
DRVDIR = $(PWD)/driver
LIBDIR = $(PWD)/api

SRC := $(wildcard api/*.c)
OBJ := $(SRC:%.c=%.o)
OBJ := $(filter-out api/main.o, $(OBJ))
TAR := api/main.c api/desktop.c api/gba.c api/temperature.c api/photoalbum.c api/music.c api/login.c api/video.c api/photograph.c

CROSS = arm-none-linux-gnueabi

CC = $(CROSS)-gcc

CPPFLAGS += -I ./include
CPPFLAGS += -DDEBUG

LDFLAGS  += -L ./lib
LDFLAGS  += -lpthread
LDFLAGS  += -lcommon
LDFLAGS  += -lpic
LDFLAGS  += -lm
LDFLAGS  += -Wl,-rpath=./lib

main:$(TAR)
	$(MAKE) -C $(LIBDIR)
	$(CC) $(TAR) -o $@ $(CPPFLAGS) $(LDFLAGS)
#	cp main ./jpeg ./bin ~/tftp/ -rf	

clean:
	$(RM) $(OBJ) main
	$(MAKE) clean -C $(LIBDIR)
	$(MAKE) clean -C $(DRVDIR)

distclean:clean
	$(RM) ./bin/*